#ifndef	_SERVER_TASK_H_
#define	_SERVER_TASK_H_

#include "rthreadpool.h"
#include "rtask.h"

#include <json/reader.h>
#include <json/json.h>
using namespace	Json ;

class server_task : public rthreadtask
{
	public:
		server_task( rtask& r_task ) : m_task(r_task), mb_downloading(false)
		{
			pthread_mutex_init(&m_lock, NULL) ;
		}
		
		virtual ~server_task()
		{
			pthread_mutex_destroy(&m_lock) ;
		}
		
		virtual void run();
		bool read();
		bool parse(const string& s_json);
		bool do_update(const Value& root);
		void do_daemon_update(const string& s_new_version, const string& s_path);
		bool download( const string& s_path );
		int compare_version( string s_local_version, string s_server_version );
		int android_system( const string& s_commamd );

		rtask& m_task ;
		pthread_mutex_t m_lock ;
		bool mb_downloading ;
};

#endif	// _SERVER_TASK_H_
